package com.um.jdy.app.activity.controller;

import com.um.jdy.app.activity.entity.dto.FullReduceGoodsPageDTO;
import com.um.jdy.app.activity.entity.dto.GroupGoodsPageDTO;
import com.um.jdy.app.activity.entity.dto.SeckillGoodsDTO;
import com.um.jdy.app.activity.entity.vo.FullReduceGoodsItemVO;
import com.um.jdy.app.activity.entity.vo.GroupDetailVO;
import com.um.jdy.app.activity.entity.vo.GroupGoodsItemVO;
import com.um.jdy.app.activity.entity.vo.SeckillTimesVO;
import com.um.jdy.app.activity.manager.ActivityManager;
import com.um.springboot.starter.entity.Page;
import com.um.springboot.starter.orm.entity.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 活动
 * @author renjunwei
 * @date 2020/11/11 09:40
 */
@Api(tags = "活动")
@RestController
@RequestMapping("/api/v1/activity/")
public class ActivityController {


    @Autowired
    ActivityManager activityManager;

    /******************************** 拼团活动 ********************************/

    /**
     * 分页查询拼团商品
     * @param dto
     * @return
     */
    @ApiOperation("分页查询拼团商品")
    @GetMapping("group/goods_page")
    public Response<Page<GroupGoodsItemVO>> getGroupGoodsPage(@ModelAttribute GroupGoodsPageDTO dto){
        return Response.success(activityManager.getGroupGoodsPage(dto));
    }

    /**
     * 查询拼团推荐商品
     * @return
     */
    @ApiOperation("查询拼团推荐商品")
    @GetMapping("group/recommend_goods")
    public Response getGroupRecommendGoodsList(){
        return Response.success(activityManager.getGroupGoodsList(4));
    }

    /**
     * 查询团详情
     * @param market_group_id
     * @return
     */
    @ApiOperation("查询团详情")
    @GetMapping("group/{market_group_id}")
    public Response<GroupDetailVO> getGroup(@ApiParam("拼团ID") @PathVariable String market_group_id){
        return Response.success(activityManager.getGroup(market_group_id));
    }

    /******************************** 秒杀活动 ********************************/


    /**
     * 查询秒杀活动场次
     * @return
     */
    @ApiOperation("查询秒杀活动场次")
    @GetMapping("seckill/times")
    public Response<List<SeckillTimesVO>> getSeckillTimesList(){
        return Response.success(activityManager.getSeckillTimesList());
    }

    /**
     * 查询秒杀场次商品
     * @param dto
     * @return
     */
    @ApiOperation("查询秒杀场次商品")
    @GetMapping("seckill/goods")
    public Response getSeckillGoodsList(@ModelAttribute SeckillGoodsDTO dto){
        return Response.success(activityManager.getSeckillGoodsList(dto, 999));
    }

    /************************************ 满减活动 begin****************************************/

    /**
     * 分页查满减商品
     * @param dto
     * @return
     */
    @ApiOperation("分页查满减商品")
    @GetMapping("full_reduce/get_goods_page")
    public Response<Page<FullReduceGoodsItemVO>> getFullReduceGoodsPage(@ModelAttribute FullReduceGoodsPageDTO dto){
        return Response.success(activityManager.getFullReduceGoodsPage(dto));
    }

    /************************************ 满减活动 end ****************************************/

}
